<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="学院" prop="xyId">
            <el-select v-model="queryParams.xyId" @change="handlelistPronj" filterable placeholder="请选择">
              <el-option v-for="item in proxyList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item v-if="queryParams.xyId != null" label="年级" prop="njId">
            <el-select v-model="queryParams.njId" @change="handlelistProzy" filterable placeholder="请选择">
              <el-option v-for="item in pronjList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item v-if="queryParams.njId != null" label="专业" prop="zyId">
            <el-select v-model="queryParams.zyId" @change="handlelistProbj" filterable placeholder="请选择">
              <el-option v-for="item in prozyList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item v-if="queryParams.zyId != null" label="班级" prop="clId">
            <el-select v-model="queryParams.clId" @change="handleQuery" filterable placeholder="请选择">
              <el-option v-for="item in probjList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="学生姓名" prop="stName">
            <el-input v-model="queryParams.stName" placeholder="请输入学生姓名" clearable @input="handleQuery"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="项目类型" prop="type">
            <el-select v-model="queryParams.type" placeholder="请选择项目类型" clearable @change="handleQuery">
              <el-option v-for="dict in dict.type.pro_ld_type" :key="dict.value" :label="dict.label"
                :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="劳动项目" prop="name">
            <el-input v-model="queryParams.name" placeholder="请输入劳动项目" clearable @input="handleQuery"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="审批/批阅状态" label-width="120px" prop="status">
            <el-select v-model="queryParams.status" placeholder="请选择状态 " clearable @change="handleQuery">
              <el-option v-for="dict in dict.type.pro_audit" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="1">
          <el-form-item label="">
            <!-- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> -->
            <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="8">
        <el-button :disabled="ids.length === 0" type="primary" @click="batchAudit">批量通过</el-button>
        <el-button :disabled="ids.length === 0" @click="batchOverru">批量驳回</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="proldList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" :selectable="selectable" />
      <el-table-column label="学生姓名" align="center" prop="stName" />
      <el-table-column label="学号" align="center" prop="stNumber" />
      <el-table-column label="学院" align="center" prop="xyName" />
      <el-table-column label="班级" align="center" prop="bjName" />
      <el-table-column label="项目类型" align="left" prop="typeName" />
      <el-table-column label="劳动项目" align="center" prop="name" />
      <el-table-column label="积分数" align="center" prop="new_count" width="80" />
      <el-table-column label="审批/批阅状态 " align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.pro_audit" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="提交时间" align="center" prop="createTime" />
      <el-table-column label="审批/批阅" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handlePass(scope.row)"
            v-if="scope.row.status=='1'"
            v-hasPermi="['project:prold:edit']"
          >审核</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['project:prold:edit']"
            v-if="scope.row.status=='2' || scope.row.status=='3'"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
            v-hasPermi="['project:prold:remove']"
          >删除</el-button>
          <el-button
            v-show="scope.row.status === '2'"
            size="mini"
            type="text"
            @click="handleRepulse(scope.row)"
            v-hasPermi="['project:prold:repulse']"
          >退回</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改宿舍/教/实验劳动对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="项目类型" prop="typeName">
          <el-input v-model="form.typeName" placeholder="请输入项目类型" readOnly/>
        </el-form-item>
        <el-form-item label="学生姓名" prop="stName">
          <el-input v-model="form.stName" placeholder="请输入学生姓名" readOnly/>
        </el-form-item>
        <el-form-item label="学号" prop="stNumber">
          <el-input v-model="form.stNumber" placeholder="学号" readOnly/>
        </el-form-item>
        <el-form-item label="学院" prop="xyName">
          <el-input v-model="form.xyName" placeholder="学院" readOnly/>
        </el-form-item>
        <el-form-item label="年级" prop="njName">
          <el-input v-model="form.njName" placeholder="年级" readOnly/>
        </el-form-item>
        <el-form-item label="专业" prop="zyName">
          <el-input v-model="form.zyName" placeholder="专业" readOnly/>
        </el-form-item>
        <el-form-item label="班级" prop="bjName">
          <el-input v-model="form.bjName" placeholder="班级" readOnly/>
        </el-form-item>
        <el-form-item label="劳动项目" prop="name" v-if="form.type=='1'||form.type=='2'||form.type=='3'||form.type=='9'||form.type=='10'||form.type=='11'">
          <el-input v-model="form.name" placeholder="请输入劳动项目" readOnly/>
        </el-form-item>
        <el-form-item label="劳模报告主题" label-width="100px" prop="name" v-if="form.type=='4'">
          <el-input v-model="form.name" placeholder="请输入劳模报告主题" readOnly/>
        </el-form-item>
        <el-form-item label="项目名称"  prop="name" v-if="form.type=='5'">
          <el-input v-model="form.name" placeholder="请输入项目名称" readOnly/>
        </el-form-item>
        <el-form-item label="比赛名称"  prop="name" v-if="form.type=='6'|| form.type=='7'">
          <el-input v-model="form.name" placeholder="请输入比赛名称" readOnly/>
        </el-form-item>
        <el-form-item label="活动名称"  prop="name" v-if="form.type=='8'">
          <el-input v-model="form.name" placeholder="请输入活动名称" readOnly/>
        </el-form-item>
        <el-form-item label="报告人"  prop="userName" v-if="form.type=='4'">
           <el-input v-model="form.userName" placeholder="请输入报告人" readOnly/>
        </el-form-item>
        <el-form-item label="项目负责人"  prop="proLdUserList" v-if="form.type=='5'">
            <div v-for="item in form.proLdUserList" :key="item.id">
               <el-input v-model="item.stName" placeholder="请输入项目负责人" readOnly/>
            </div>
        </el-form-item>
        <el-form-item label="团队负责人"  prop="proLdUserList" v-if="form.type=='6'">
           <div v-for="item in form.proLdUserList" :key="item.id">
              <el-input v-model="item.stName" placeholder="请输入项目负责人" readOnly/>
           </div>
        </el-form-item>
        <el-form-item label="报告时间" prop="bgTime" v-if="form.type=='4'">
        <el-input value-format="yyyy-MM-dd" v-model="form.bgTime" placeholder="请输入报告时间" readOnly/>
          <!--<el-date-picker clearable
            v-model="form.bgTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入报告时间"
            disabled>
          </el-date-picker>-->
        </el-form-item>
        <el-form-item label="结题时间" prop="bgTime" v-if="form.type=='5'">
        <el-input value-format="yyyy-MM-dd" v-model="form.bgTime" placeholder="请输入结题时间" readOnly/>
          <!--<el-date-picker clearable
            v-model="form.bgTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入结题时间"
            disabled>
          </el-date-picker>-->
        </el-form-item>
        <el-form-item label="比赛时间" prop="bgTime" v-if="form.type=='6'||form.type=='7'">
        <el-input value-format="yyyy-MM-dd" v-model="form.bgTime" placeholder="请输入比赛时间" readOnly/>
          <!--<el-date-picker clearable
            v-model="form.bgTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入比赛时间"
            disabled>
          </el-date-picker>-->
        </el-form-item>
        <el-form-item label="活动时间" prop="bgTime" v-if="form.type=='8'">
        <el-input value-format="yyyy-MM-dd" v-model="form.bgTime" placeholder="请输入活动时间" readOnly/>
          <!--<el-date-picker clearable
            v-model="form.bgTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入活动时间"
            disabled>
          </el-date-picker>-->
        </el-form-item>
        <el-form-item v-if="form.type=='1'||form.type=='2'||form.type=='3'||form.type=='9'||form.type=='10'||form.type=='11'" label="开始时间" prop="startTime">
        <el-input value-format="yyyy-MM-dd" v-model="form.startTime" placeholder="请输入开始时间" readOnly/>
          <!--<el-date-picker clearable
            v-model="form.startTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入开始时间"
            disabled>
          </el-date-picker>-->
        </el-form-item>
        <el-form-item v-if="form.type=='1'||form.type=='2'||form.type=='3'||form.type=='9'||form.type=='10'||form.type=='11'" label="结束时间" prop="stopTime">
        <el-input value-format="yyyy-MM-dd" v-model="form.stopTime" placeholder="请输入结束时间" readOnly/>
          <!--<el-date-picker clearable
            v-model="form.stopTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入结束时间"
            disabled>
          </el-date-picker>-->
        </el-form-item>
        <el-form-item label="主办单位" prop="dwName" v-if="form.type=='7'">
          <el-input v-model="form.dwName" placeholder="请输入主办单位" readOnly/>
        </el-form-item>
        <el-form-item v-if="form.type=='5'||form.type=='6'||form.type=='7'" label="级别" prop="jbName">
          <el-input v-model="form.jbName" placeholder="请输入级别" readOnly/>
        </el-form-item>
        <el-form-item v-if="form.type=='6'||form.type=='7'" label="等级名称" prop="djName">
          <el-input v-model="form.djName" placeholder="请输入等级名称" readOnly/>
        </el-form-item>
        <el-form-item v-if="form.type=='6'" label="位次名称" prop="wcName">
          <el-input v-model="form.wcName" placeholder="请输入位次名称" readOnly/>
        </el-form-item>
        <el-form-item label="劳动地点" prop="position" v-if="form.type=='1'||form.type=='2'||form.type=='3'||form.type=='9'||form.type=='10'||form.type=='11'">
          <el-input v-model="form.position" placeholder="请输入位置" readOnly/>
        </el-form-item>
        <el-form-item label="劳动说明">
          <el-input type="textarea" v-model="form.content" :min-height="192" readOnly/>
        </el-form-item>
        <el-form-item label="积分数" prop="dfCount" v-if="form.status=='2'||form.status=='3'">
          <el-input  v-model="form.new_count" :min-height="192" readOnly/>
        </el-form-item>
        <el-form-item label="文件" prop="proFileList">
        <div v-for="item in form.proFileList" :key="item.id" class="fileImage">
                <img :src="item.file" alt="" v-if="item.fileType == 'image'"
                     class="w-100 h-150 mr-100 one_overflow w-136 fs-140 col333 pointer" @click="download(item.file)"/>

          <video :src="item.file" controls v-if="item.fileType == 'video'"
                 class="w-100 h-150 mr-100 one_overflow w-136 fs-140 col333 pointer" @click="download(item.file)"/>
                <div class="one_overflow w-200 fs-14 col333 pointer"
                     v-if="item.fileType == 'file'"
                     @click="download(item.file)">{{ item.fileName }}</div>

             </div>
             </el-form-item>
        <el-form-item label="驳回理由"  prop="markName" v-if="form.status=='3'">
          <el-input v-model="form.markName" type="textarea" placeholder="请输入驳回理由"  :readOnly="isReadOnly"/>
        </el-form-item>
        <el-form-item label="评语"  prop="markName" v-if="form.status=='1'||form.status=='2'">
          <el-input v-model="form.markName" type="textarea" placeholder="请输入评语"  :readOnly="isReadOnly"/>
        </el-form-item>
        <el-dialog title = "驳回理由" :visible.sync="open4" :rules="rules" width="400px"  height="1500px" append-to-body class="w-1000 mr-100 ml-100 mt-300 mb-100">
          <el-form-item label="驳回理由"  prop="remarkName">
          <el-input v-model="form.remarkName" type="textarea" placeholder="请输入驳回理由" />
          </el-form-item>
          <el-button  type="primary"  @click="submitReject">确 定</el-button>
                  <el-button @click="cancelBh">取 消</el-button>
        </el-dialog>
        <!--<el-divider content-position="center">劳动关联用户信息</el-divider>-->
        <!-- <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddProLdUser">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteProLdUser">删除</el-button>
          </el-col>
        </el-row> -->
        <!-- <el-table :data="proLdUserList" :row-class-name="rowProLdUserIndex" @selection-change="handleProLdUserSelectionChange" ref="proLdUser">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="用户姓名" prop="xyName" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.xyName" placeholder="请输入用户ID" />
            </template>
          </el-table-column>
        </el-table> -->
      </el-form>
      <div slot="footer" class="dialog-footer">

        <!--<el-button v-if="isUpdate=='2'" type="primary" @click="submitPass">通过</el-button>
        <el-button v-if="isUpdate=='3'" type="primary" @click="submitReject">驳回</el-button>-->
        <el-button  v-if="isUpdate=='2'" type="primary" @click="submitPass">通过</el-button>
        <el-button  v-if="isUpdate=='2'" type="primary" @click="rejectRemark">驳回</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

     <!-- 通过 -->
    <el-dialog :title="title" :visible.sync="open2" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="评分" prop="markNumber">
          <el-input v-model="form.markNumber" placeholder="请输入评分" />
        </el-form-item>
        <el-form-item label="评语" prop="markName">
          <el-input v-model="form.markName" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitPass">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
         <!-- 驳回 -->
    <el-dialog :title="title" :visible.sync="open3" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <!-- <el-form-item label="评分" prop="markNumber">
          <el-input-number v-model="form.markNumber" placeholder="请输入评分" />
        </el-form-item> -->
        <el-form-item label="驳回原因" prop="markName">
          <el-input v-model="form.markName" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitReject">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listProld,
  getProld,
  delProld,
  addProld,
  updateProld,
  pass,
  reject,
  listProxy,
  listProzy,
  listPronj,
  listProbj,
  listProxx,
  repulse
} from "@/api/project/prold";

export default {
  name: "Prold",
  dicts: ['pro_ld_type', 'pro_audit'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedProLdUser: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 宿舍/教/实验劳动表格数据
      proldList: [],
      // 劳动关联用户表格数据
      proLdUserList: [],
      prozyList:[],
      proxyList:[],
      proxxList:[],
      pronjList:[],
      probjList:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open2: false,
      open3: false,
      open4: false,
     // isDisabled: false,
      isReadOnly: false,


      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        type: null,
        name: null,
        bgTime: null,
        startTime: null,
        stopTime: null,
        dwName: null,
        jbName: null,
        djName: null,
        wcName: null,
        position: null,
        content: null,
        status: null,
        year: null,
        month: null,
        day: null,
        markNumber: null,
        markName: null,
        file: null,
        fileType: null,
        xyId: null,
        xxId: null,
        zyId: null,
        njId: null,
        clId: null,
        formTitle:{

        }
      },
      formTitle:{
       // markName: '评语/驳回理由'
       markName: ''
      },
      isUpdate: false,
      // 表单参数
      form: {},
      rules: {
        remarkName: [
          { required: true, message: "请输入内容", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getInit();
  },
  methods: {
    getInit(){
      listProxx().then(response => {
        this.proxxList = response.rows;
      });
      listProxy().then(response => {
        this.proxyList = response.rows;
      });
      listProzy().then(response => {
        this.prozyList = response.rows;
      });
      listPronj().then(response => {
        this.pronjList = response.rows;
      });
      listProbj().then(response => {
        this.probjList = response.rows;
      });
    },
      download(url) {
        // window.location.href = url
        window.open(url);
      },
    /** 查询宿舍/教/实验劳动列表 */
    getList() {
      this.loading = true;
      listProld(this.queryParams).then(response => {
        this.proldList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.open2 = false;
      this.open3 = false;
      this.reset();
    },
    cancelBh(){
    this.open4 = false;
    this.form.markName = '';
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        type: null,
        name: null,
        bgTime: null,
        startTime: null,
        stopTime: null,
        dwName: null,
        jbName: null,
        djName: null,
        wcName: null,
        position: null,
        content: null,
        createTime: null,
        status: null,
        year: null,
        month: null,
        day: null,
        markNumber: null,
        markName: null,
        file: null,
        fileType: null,
        xyId: null,
        xxId: null,
        zyId: null,
        njId: null,
        clId: null,
        //isDisabled: false,
        isReadOnly: false,
      };
      this.proLdUserList = [];
      this.isUpdate = false;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加宿舍/教/实验劳动";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
     // this.reset();
      const id = row.id || this.ids
      getProld(id).then(response => {
         if(response.data.proFileList.length>0){
        response.data.proFileList.forEach(item =>{
          item.file = process.env.VUE_APP_BASE_FILE + item.file;
        })
       }
        this.form = response.data;
        this.form.status = response.data.status;
        this.proLdUserList = response.data.proLdUserList;
        //this.isDisabled = true;
        this.isReadOnly = true;
        this.open = true;
        this.title = "基础劳动详情";
      });
    },
    /** 审核按钮操作 */
    handlePass(row) {
      //this.reset();
      const id = row.id || this.ids;
      getProld(id).then(response => {
         if(response.data.proFileList.length>0){
        response.data.proFileList.forEach(item =>{
          item.file = process.env.VUE_APP_BASE_FILE + item.file;
        })
       }
        this.form = response.data;
       // this.form.status = '2';

        this.proLdUserList = response.data.proLdUserList;
        this.isUpdate = '2';
        //this.isDisabled = false;
        this.isReadOnly = false;
        this.open = true;
        //this.formTitle.markName = "评语";
        this.title = "审核";
      });
    },

    handleRepulse(row) {
      this.$modal.confirm('是否打回宿舍/教/实验劳动编号为"' + row.id + '"的数据项？').then(function() {
        return repulse(row);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("打回成功");
      }).catch(() => {});
    },

       /**驳回-驳回理由 */
       rejectRemark() {
           this.open4 = true;
           this.form.markName = '';

       },
        /** 提交按钮 */
    submitPass() {
      this.form.proLdUserList = this.proLdUserList;
      if (this.form.id != null) {
        pass([this.form]).then(response => {
          this.$modal.msgSuccess("通过成功");
          this.open = false;
          this.getList();
        });
      }
    },
        /** 提交按钮 */
    submitReject() {
      this.form.markName = this.form.remarkName;
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.proLdUserList = this.proLdUserList;
          if (this.form.id != null) {
            reject([this.form]).then(response => {
              this.$modal.msgSuccess("驳回成功");
              this.open = false;
              this.open4 = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.proLdUserList = this.proLdUserList;
          if (this.form.id != null) {
            updateProld(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除宿舍/教/实验劳动编号为"' + ids + '"的数据项？').then(function() {
        return delProld(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
	/** 劳动关联用户序号 */
    rowProLdUserIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 劳动关联用户添加按钮操作 */
    handleAddProLdUser() {
      let obj = {};
      obj.userId = "";
      obj.type = "";
      this.proLdUserList.push(obj);
    },
    /** 劳动关联用户删除按钮操作 */
    handleDeleteProLdUser() {
      if (this.checkedProLdUser.length == 0) {
        this.$modal.msgError("请先选择要删除的劳动关联用户数据");
      } else {
        const proLdUserList = this.proLdUserList;
        const checkedProLdUser = this.checkedProLdUser;
        this.proLdUserList = proLdUserList.filter(function(item) {
          return checkedProLdUser.indexOf(item.index) == -1
        });
      }
    },
    /** 复选框选中数据 */
    handleProLdUserSelectionChange(selection) {
      this.checkedProLdUser = selection.map(item => item.index)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('project/prold/export', {
        ...this.queryParams
      }, `prold_${new Date().getTime()}.xlsx`)
    },

    handlelistProxy(){
    listProxy(map).then(response => {
        this.proxyList = response.rows;
      });
    },
    handlelistPronj(value) {
      var map = {};
      map.pId = value;
      listPronj(map).then(response => {
        this.pronjList = response.rows;
      });
      this.queryParams.njId = null;
      this.queryParams.clId = null;
      this.queryParams.zyId = null;
      this.handleQuery();
    },
    handlelistProzy(value) {
      var map = {};
      map.pId = value;
      listProzy(map).then(response => {
        this.prozyList = response.rows;
      });
      this.queryParams.clId = null;
      this.queryParams.zyId = null;
      this.handleQuery();
    },
    handlelistProbj(value) {
      var map = {};
      map.pId = value;
      listProbj(map).then(response => {
        this.probjList = response.rows;
      });
      this.queryParams.clId = null;
      this.handleQuery();
    },

    // 判断某行是否可选
    selectable(row) {
      return row.status == '1';
    },
    batchAudit() {
      this.$confirm('是否确认同时通过"' + this.ids.length + '"条基础劳动？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'success',
      }).then(() => {
        let dataId = [];
        this.ids.forEach(idItem => {
          this.proldList.forEach(item => {
            if (idItem == item.id) {
              dataId.push(item);
            }
          })
        });
        pass(dataId).then(() => {
          this.ids = [];
          this.getList();
          this.$modal.msgSuccess("通过成功");
        });
      }).catch(() => { });
    },
    batchOverru() {
      this.$confirm('是否确认驳回"' + this.ids.length + '"条基础劳动？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        showInput: true,  // 启用输入框
        inputPlaceholder: '请输入驳回原因',  // 输入框提示文本
      }).then(input => {
        if (!input.value) {
          this.$modal.msgWarning("请添写驳回理由!")
          return
        };
        let dataId = [];
        this.ids.forEach(idItem => {
          this.proldList.forEach(item => {
            if (idItem == item.id) {
              dataId.push({ ...item, markName: input.value });
            }
          })
        });
        reject(dataId).then(() => {
          this.ids = [];
          this.open = false;
          this.getList();
          this.$modal.msgSuccess("驳回成功");
        });
      }).catch(() => { });
    },
  }
};
</script>
